﻿//element cache
var J_searchcard = $("#J_searchcard");
var J_searchcard_popup = $("#J_searchcard_popup");
var J_searchcard_popup_noresult = $("#J_searchcard_popup_noresult");
var J_formprice = $("#J_formprice");

$(document).ready(function () {
    //公告滚动
    var notice = $("#J_notice");
    if (notice.length > 0) {
        var notice_html = notice.html();
        if (notice_html.length > 25) {
            notice.html("<marquee direction='left' scrollamount='2' scrolldelay='1' onmouseover='this.stop()' onmouseover='this.stop()' onmouseout='this.start()'>" + notice_html + "</marquee>");
        };
    };

    //筛选
    $("#J_filter").find("a.more").click(function () {
        var t = $(this);
        t.toggleClass("open");
        t.prev("p.more").slideToggle();
        return false;
    });

    //pagesize切换
    $("#J_pagesize a").click(function () {
        $("#J_pagesize a").removeClass("now");
        $(this).addClass("now");
        $(this).nextAll("input").val($(this).html());
    });

    //价格限制
    J_formprice.find("input").keyup(function () {
        var t = $(this);
        var val = t.val().replace(/(^\s*)|(\s*$)/g, "");
        var reg = /[^\d]$/;
        if (val.length > 0) {
            val = val.replace(reg, "");
            t.val(val);
        };
    });


    //返回顶部
    var J_top = $("#J_top");
    var tops = J_top.offset().top;
    //J_top.css({ top: $(window).scrollTop() + tops });
    $(window).scroll(function () { J_top.animate({ top: $(window).scrollTop() + tops }, { queue: false, duration: 500 }) });
    J_top.click(function () { $("html,body").animate({ scrollTop: '0' }, 800) });
});